css: Use GArray in GtkCssComputedValues
authorBenjamin Otte <otte@redhat.com>
Wed, 25 Jan 2012 17:26:56 +0000 (18:26 +0100)
committerBenjamin Otte <otte@redhat.com>
Wed, 25 Jan 2012 18:05:33 +0000 (19:05 +0100)
GValueArray is deprecated in glib. Also, bump the required glib version
for g_array_set_clear_func().

configure.ac
gtk/gtkcsscomputedvalues.c
gtk/gtkcsscomputedvaluesprivate.h

index 424f455d67ca27c3663264f0dfcec41294dad4d5..d8da8bb74e985dd9bfc9b08c2996678d7baf7042 100644 (file)
@@ -39,7 +39,7 @@ AC_CONFIG_AUX_DIR([build-aux])
 m4_define([gtk_binary_version], [3.0.0])
 
 # required versions of other packages
-m4_define([glib_required_version], [2.31.11])
+m4_define([glib_required_version], [2.31.13])
 m4_define([pango_required_version], [1.29.0])
 m4_define([atk_required_version], [2.1.5])
 m4_define([cairo_required_version], [1.10.0])
index 8423be729ec1d4f40c1290c323cfb30d65054d59..9a3c1b0f462952fb0366aa2b07b194c316c6e57b 100644 (file)
@@ -35,7 +35,7 @@ gtk_css_computed_values_dispose (GObject *object)
 
   if (values->values)
     {
-      g_value_array_free (values->values);
+      g_array_free (values->values, TRUE);
       values->values = NULL;
     }
   if (values->sections)
@@ -92,9 +92,12 @@ _gtk_css_computed_values_compute_value (GtkCssComputedValues *values,
   parent = gtk_style_context_get_parent (context);
 
   if (values->values == NULL)
-    values->values = g_value_array_new (id + 1);
-  while (values->values->n_values <= id)
-    g_value_array_append (values->values, NULL);
+    {
+      values->values = g_array_new (FALSE, TRUE, sizeof (GValue));
+      g_array_set_clear_func (values->values, (GDestroyNotify) g_value_unset);
+    }
+  if (id <= values->values->len)
+   g_array_set_size (values->values, id + 1);
 
   /* http://www.w3.org/TR/css3-cascade/#cascade
    * Then, for every element, the value for each property can be found
@@ -158,14 +161,14 @@ _gtk_css_computed_values_compute_value (GtkCssComputedValues *values,
   if (specified)
     {
       _gtk_css_style_property_compute_value (prop,
-                                             g_value_array_get_nth (values->values, id),
+                                             &g_array_index (values->values, GValue, id),
                                              context,
                                              specified);
     }
   else
     {
       const GValue *parent_value;
-      GValue *value = g_value_array_get_nth (values->values, id);
+      GValue *value = &g_array_index (values->values, GValue, id);
       /* Set NULL here and do the inheritance upon lookup? */
       parent_value = _gtk_style_context_peek_property (parent,
                                                        _gtk_style_property_get_name (GTK_STYLE_PROPERTY (prop)));
@@ -193,10 +196,10 @@ _gtk_css_computed_values_get_value (GtkCssComputedValues *values,
   g_return_val_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values), NULL);
 
   if (values->values == NULL ||
-      id >= values->values->n_values)
+      id >= values->values->len)
     return NULL;
 
-  v = g_value_array_get_nth (values->values, id);
+  v = &g_array_index (values->values, GValue, id);
   if (!G_IS_VALUE (v))
     return NULL;
 
index b382b25c2b850801de4b21a118d5259828220d48..74a15ec10e93d2ad726874671af19fbd41ddf22c 100644 (file)
@@ -42,7 +42,7 @@ struct _GtkCssComputedValues
 {
   GObject parent;
 
-  GValueArray           *values;
+  GArray                *values;
   GPtrArray             *sections;
 };